package org.soenea.doitall.application.dispatcher;

import java.io.IOException;
import javax.servlet.ServletException;
import org.soenea.doitall.domain.command.InviteMemberCommand;
import org.soenea.doitall.domain.command.exception.*;
import org.dsrg.soenea.domain.command.CommandException;

public class InviteMember extends Dispatcher {
	@Override
	public void execute() throws ServletException, IOException {
		try {
			new InviteMemberCommand(this.myHelper).execute();
			relativeRedirect("viewgroup");
		} catch (MemberNotFoundException e) {
			relativeRedirect("viewgroup?error=membernotfound");
		} catch (MemberAlreadyInGroupException e) {
			relativeRedirect("viewgroup?error=memberalreadyingroup");
		} catch (final CommandException e) {
			throw new ServletException(e);
		}
	}
}
